//
//  BaiKeMainSearchView.m
//  BaseProject
//
//  Created by mac on 2020/12/21.
//  Copyright © 2020 王洋. All rights reserved.
//

#import "BaiKeMainSearchView.h"
#import "SearchResultSegViewController.h"
@interface BaiKeMainSearchView ()
@property(nonatomic,strong)UIView *greyView;
@property(nonatomic,strong)UIImageView *leftIV;
@property(nonatomic,strong)UILabel *titleLab;
@end

@implementation BaiKeMainSearchView
- (instancetype)initWithFrame:(CGRect)frame
{
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = WhiteColor;
        [self greyView];
        [self leftIV];
        self.titleLab.text = @"搜搜你想知道的百科知识";
    }
    return self;
}
#pragma mark - click
- (void)clickGreyView:sender
{
    SearchResultSegViewController *vc = [[SearchResultSegViewController alloc] init];
    vc.selectIndex = SearchResultSegType_baike;
    [self.parentVC.navigationController pushViewController:vc animated:YES];
}
#pragma mark - lazy懒加载
- (UIView *)greyView
{
    if (!_greyView) {
        UIView *view = [[UIView alloc]init];
        view.backgroundColor = rgba(245, 245, 245, 1);
        view.frame = CGRectMake(16*ADAPTER_WIDTH, kStatusBarHeight + 7, self.width - 32*ADAPTER_WIDTH, 30);
        [self addSubview:view];
        view.layer.cornerRadius = 15;
        view.layer.masksToBounds = YES;
        UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(clickGreyView:)];
        view.userInteractionEnabled = YES;
        [view addGestureRecognizer:tap];
        _greyView = view;
    }
    return _greyView;
}
- (UIImageView *)leftIV
{
    if (!_leftIV) {
        UIImageView *iv = [[UIImageView alloc]init];
        [self.greyView addSubview:iv];
        iv.image = [UIImage imageNamed:@"sousuo"];
        iv.frame = CGRectMake(14, 7.5, 15, 15);
        _leftIV = iv;
    }
    return _leftIV;
}
- (UILabel *)titleLab
{
    if (!_titleLab) {
        UILabel *lab = [[UILabel alloc]init];
        [self.greyView addSubview:lab];
        lab.font = [UIFont systemFontOfSize:13 weight:UIFontWeightRegular];
        lab.textColor = kColor102;
        lab.textAlignment = NSTextAlignmentLeft;
        lab.numberOfLines = 1;
        lab.frame = CGRectMake(self.leftIV.right + 7*ADAPTER_WIDTH, 0, self.greyView.width - 100*ADAPTER_WIDTH, self.greyView.height);
        _titleLab = lab;
    }
    return _titleLab;
}
@end
